﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Algoritmia.DataStructures.Digraphs
{
    public class UndirectedDigraph<T> : InverseAdjacencyDigraph<T>
    {
        public UndirectedDigraph(IEnumerable<T> vertices=null,
                       IEnumerable<Tuple<T,T>> edges=null)
            : base(vertices,edges,directed:false)
        {
        }

        public UndirectedDigraph(IEnumerable<T> vertices = null,
                       IEnumerable<KeyValuePair<T, IEnumerable<T>>> edges = null)
            : base(vertices, edges, directed: false)
        {
        }

        public override string ToString()
        {
            var sb = new StringBuilder(String.Format("{0} <{1}> [ ", GetType().Name, typeof(T).Name));

            foreach (var kv in _succs)
            {
                sb.Append(String.Format("( {0} , {1} ) ,", kv.Key, kv.Value));
            }
            sb.Append("]");
            return sb.ToString();
        }
    }
}
